/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package j2ee.impl;

import j2ee.ContainerTransactionType;
import j2ee.J2eePackage;
import j2ee.MethodType;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Container Transaction Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link j2ee.impl.ContainerTransactionTypeImpl#getMethod <em>Method</em>}</li>
 *   <li>{@link j2ee.impl.ContainerTransactionTypeImpl#getTransAttribute <em>Trans Attribute</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ContainerTransactionTypeImpl extends EObjectImpl implements ContainerTransactionType {
	/**
	 * The cached value of the '{@link #getMethod() <em>Method</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMethod()
	 * @generated
	 * @ordered
	 */
	protected MethodType method;

	/**
	 * The default value of the '{@link #getTransAttribute() <em>Trans Attribute</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTransAttribute()
	 * @generated
	 * @ordered
	 */
	protected static final String TRANS_ATTRIBUTE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getTransAttribute() <em>Trans Attribute</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTransAttribute()
	 * @generated
	 * @ordered
	 */
	protected String transAttribute = TRANS_ATTRIBUTE_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ContainerTransactionTypeImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return J2eePackage.Literals.CONTAINER_TRANSACTION_TYPE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public MethodType getMethod() {
		return method;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetMethod(MethodType newMethod, NotificationChain msgs) {
		MethodType oldMethod = method;
		method = newMethod;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, J2eePackage.CONTAINER_TRANSACTION_TYPE__METHOD, oldMethod, newMethod);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setMethod(MethodType newMethod) {
		if (newMethod != method) {
			NotificationChain msgs = null;
			if (method != null)
				msgs = ((InternalEObject)method).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - J2eePackage.CONTAINER_TRANSACTION_TYPE__METHOD, null, msgs);
			if (newMethod != null)
				msgs = ((InternalEObject)newMethod).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - J2eePackage.CONTAINER_TRANSACTION_TYPE__METHOD, null, msgs);
			msgs = basicSetMethod(newMethod, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, J2eePackage.CONTAINER_TRANSACTION_TYPE__METHOD, newMethod, newMethod));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getTransAttribute() {
		return transAttribute;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTransAttribute(String newTransAttribute) {
		String oldTransAttribute = transAttribute;
		transAttribute = newTransAttribute;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, J2eePackage.CONTAINER_TRANSACTION_TYPE__TRANS_ATTRIBUTE, oldTransAttribute, transAttribute));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case J2eePackage.CONTAINER_TRANSACTION_TYPE__METHOD:
				return basicSetMethod(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case J2eePackage.CONTAINER_TRANSACTION_TYPE__METHOD:
				return getMethod();
			case J2eePackage.CONTAINER_TRANSACTION_TYPE__TRANS_ATTRIBUTE:
				return getTransAttribute();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case J2eePackage.CONTAINER_TRANSACTION_TYPE__METHOD:
				setMethod((MethodType)newValue);
				return;
			case J2eePackage.CONTAINER_TRANSACTION_TYPE__TRANS_ATTRIBUTE:
				setTransAttribute((String)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case J2eePackage.CONTAINER_TRANSACTION_TYPE__METHOD:
				setMethod((MethodType)null);
				return;
			case J2eePackage.CONTAINER_TRANSACTION_TYPE__TRANS_ATTRIBUTE:
				setTransAttribute(TRANS_ATTRIBUTE_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case J2eePackage.CONTAINER_TRANSACTION_TYPE__METHOD:
				return method != null;
			case J2eePackage.CONTAINER_TRANSACTION_TYPE__TRANS_ATTRIBUTE:
				return TRANS_ATTRIBUTE_EDEFAULT == null ? transAttribute != null : !TRANS_ATTRIBUTE_EDEFAULT.equals(transAttribute);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (transAttribute: ");
		result.append(transAttribute);
		result.append(')');
		return result.toString();
	}

} //ContainerTransactionTypeImpl
